<form [formGroup]="contactForm" (submit)="onSubmit()">
    <input type="text" formControlName="name">
    <div *ngIf="name.touched && name.invalid && name.errors">
        <div *ngIf="name.errors.required">请填写名字</div>
        <div *ngIf="name.errors.minlength">
            名字的最小长度为{{name.errors.minlength.requiredLength}}
        </div>
        <div *ngIf="name.errors.cannotContainSpace">名字中不能包含空格</div>
        <div *ngIf="name.errors.shouldBeUnique">名字中已经存在</div>
    </div>
    <div *ngIf="name.pending">正在验证...</div>
    <button [disabled]="contactForm.invalid">提交</button>
</form>